$(function(){
	$.post('/index/Trade/lists',function(msg){
		var dom = document.getElementById("container");
		// 初始化
		var myChart = echarts.init(dom);
		var app = {};
		option = null;
		var xAxisData = [];
		var data1 = [];
		var data2 = [];
		var leg = [];
		var seri = [];
		if (msg.times) {
			xAxisData = msg.times;
		}
		if (msg.group && msg.data) {
			for (var i =0; i<msg.group.length;i++) {
				var arr = {};
				leg.push(msg.group[i].name);
				arr.name = msg.group[i].name;
				arr.type = 'bar';
				arr.data = [];
				for(var k =0;k<msg.times.length;k++){
					var num = parseInt(msg.data[i][msg.times[k]]);
					arr['data'].push(num);
				}
				arr.animationDelay = function (idx) {
					return idx*10+100;
				}
				seri.push(arr);
			}
		}
		option = {
		    title: {
		        text: '交易行情'
		    },
		    legend: {
		        data: leg,
		        align: 'left'
		    },
		    toolbox: {
		        // y: 'bottom',
		        feature: {
		            magicType: {
		                type: ['stack', 'tiled']
		            },
		            dataView: {},
		            saveAsImage: {
		                pixelRatio: 2
		            }
		        }
		    },
		    tooltip: {},
		    xAxis: {
		        data: xAxisData,
		        silent: false,
		        splitLine: {
		            show: false
		        }
		    },
		    yAxis: {
		    },
		    series: seri,
		    animationEasing: 'elasticOut',
		    animationDelayUpdate: function (idx) {
		        return idx * 5;
		    }
		};
		if (option && typeof option === "object") {
		    myChart.setOption(option, true);
		}
	},'json');
})